﻿using An_Im.Extension.Contract;
using Microsoft.Office.Interop.PowerPoint;
using System.Collections.Generic;

namespace An_Im.Extension.Contract
{

    /// <summary>
    /// 命令对象的基类。
    /// </summary>
    public abstract class AnImCommandBase : IAnImCommand
    {
        public string Name { get; }

        public string Description { get; }

        public IList<ParaNameValuePair> DefaultParas { get; }

        public CommandExecuteHandler CommandExecuteMethod { get; private set; } = null;



        public bool VBAExportable { get; set; }
        public bool VBSExportable { get; set; }
        public bool PowerShellExportable { get; set; }
        public IExtend AddIn { get; set; }
        public virtual string ExportVBACode()
        {
            return ExportVBACode(DefaultParas);
        }



        public virtual string ExportVBACode(IList<ParaNameValuePair> customParas)
        {
            return string.Empty;
        }

        public virtual string ExportVBSCode()
        {
            return ExportVBSCode(DefaultParas);
        }

        public virtual string ExportVBSCode(IList<ParaNameValuePair> customParas)
        {
            return string.Empty;
        }

        public virtual string ExportPowerShellCode()
        {
            return ExportPowerShellCode(DefaultParas);
        }

        public virtual string ExportPowerShellCode(IList<ParaNameValuePair> customParas)
        {
            return string.Empty;
        }

        /// <summary>
        /// 执行。
        /// </summary>
        public void Excute(Application app)
        {
            Excute(app, DefaultParas);
        }

        /// <summary>
        /// 执行。
        /// </summary>
        public void Excute(Application app, IList<ParaNameValuePair> paras)
        {
            CommandExecuteMethod?.Invoke(app, paras);
        }

        public AnImCommandBase(string name, string description, IList<ParaNameValuePair> paralist, CommandExecuteHandler commandExecuteHandler)
        {
            Name = name; // 名称
            Description = description; // 描述
            DefaultParas = paralist; // 参数列表
            CommandExecuteMethod = commandExecuteHandler;
        }

    }
}
